<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            margin: 100px;
            width: 460px;
        }

        .box .btn {
            height: 40px;
            margin-bottom: 5px;
        }

        .box .btn input {
            float: left;
            width: 100px;
            text-align: center;
            height: 40px;
            margin-right: 20px;
            border: 1px solid #334455;
        }

        .box .btn input:nth-child(4) {
            margin-right: 0px;
        }

        .box .wj {
            width: 460px;
            height: 400px;
            border: 1px solid #ccc;
            box-sizing: border-box;
            display: none;
        }

        .box .btn .active {
            background: orange;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="btn">
            <input type="button" class="btnList active" value="体育">
            <input type="button" class="btnList" value="娱乐">
            <input type="button" class="btnList" value="新闻">
            <input type="button" class="btnList" value="教育">

        </div>
        <div class="wj" style="display: block;">体育</div>
        <div class="wj">娱乐</div>
        <div class="wj">新闻</div>
        <div class="wj">教育</div>
    </div>
    <script>
        var btn = document.getElementsByTagName('input');   /*查找出按钮*/

        var wj = document.getElementsByClassName('wj');     /*查找出class名的元素*/

        for (var i=0; i< btn.length; i++){
            btn[i].idx = i;                         /*按钮的索引*/
            btn[i].onclick = function(){            /*每个按钮的点击事件*/
                for(var j = 0; j<btn.length; j++){
                    btn[j].className = 'btnList';           /*保留btnList  去掉active*/

                    wj[j].style.display = 'none';           /*把 wj 隐藏起来*/
                }
                this.className = 'btnList active';      /*点击的元素添加 btnList active */
                wj[this.idx].style.display = 'block';   /*class 元素 显示出来*/
            }
        }
    </script>

</body>
</html>